# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Echizen Ryoma <echizenryoma.zhang@gmail.com>
# Contributor: Martchus <martchus@gmx.net>

pkgname=network-manager-sstp
pkgver=1.3.1
pkgrel=2
pkgdesc="SSTP support for NetworkManager"
arch=('loong64' 'x86_64')
url="https://gitlab.gnome.org/GNOME/network-manager-sstp"
license=('GPL2')
depends=('libsecret' 'sstp-client')
optdepends=('ppp'
            'libnma: GUI support (GTK 3)'
            'libnma-gtk4: GUI support (GTK 4)')
makedepends=('gtk3' 'gtk4' 'libnma' 'libnma-gtk4' 'intltool' 'ppp' 'python')
source=("https://gitlab.gnome.org/GNOME/network-manager-sstp/-/archive/release-$pkgver/network-manager-sstp-release-$pkgver.tar.bz2")
sha256sums=('20ff1422a8779b5825ea0198e0d4232a27ac9b15f2dcafc04124f26bef7864d6')

build() {
  pppd_version=(`pppd --version 2>&1 | awk '{print $3}'`)
  cd network-manager-sstp-release-$pkgver

  ./autogen.sh \
    --prefix=/usr \
    --sysconfdir=/etc \
    --with-pppd-plugin-dir=/usr/lib/pppd/$pppd_version \
    --libdir=/usr/lib \
    --libexecdir=/usr/lib/NetworkManager \
    --with-libnm-glib=no \
    --enable-more-warnings=yes \
    --with-gtk4=yes
  # libnm-glib disabled due to missing libnm-gtk package
  # set_more_warnings being error by default, which adds -Werror

  make
}

package() {
  cd network-manager-sstp-release-$pkgver

  make DESTDIR="$pkgdir" dbusservicedir=/usr/share/dbus-1/system.d install
}
